import {getPartList,getCustomerList,getEmployeeList} from "../api";
import {ERROR_OK} from "../util/config";

export async function getPartLists({commit,state},forceUpdate=false) {
        if(!state.partList.length || forceUpdate){
            let {status,data} = await getPartList();
            if(status === ERROR_OK) {
                commit('getPartList',data)
            }
        }
}

export async function loadCustomerList({commit,state},force) {
    if(!state.customerList.length || force){
        let {status,data} = await getCustomerList();
        if(status === ERROR_OK) {
            commit('getCustomerList',data)
        }
    }
}

export async function loadEmployeeList({commit,state},force) {
    if(!state.employeeList.length || force){
        let {status,data} = await getEmployeeList();
        if(status === ERROR_OK) {
            commit('getEmployeeList',data.list)
        }
    }
}
export function modPart({commit},part) {

    commit('modPart',part)
}
export function modPartNum({commit},partList) {
    commit('modPartNum',partList)
}